package com.example.demo.controller;

import com.example.demo.Mappers.GetRecipeListMapper;
import com.example.demo.beans.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018-06-21.
 * 查询就诊记录
 */
@RestController
public class GetJZJLListController {
    @Autowired
    private GetRecipeListMapper mapper;
    @ResponseBody
    @RequestMapping(value = "GetJZJLList",produces = {"application/xml"})
    public GetJZJLListResponse getJZJLList(@RequestBody(required = false) GetRecipeListRequest request )
    {if(request!=null){
        //获取所有处方
        List<GetJzjlInfo> item3s=new ArrayList<>();
        item3s =mapper.getjzjlinfo(request.getCardNo(),request.getPatientID());
        //获取返回数据
        List<GetJZJLListRequestItem> items=new ArrayList<>();
        for(int i=0;i<item3s.size();i++)
        { GetJZJLListRequestItem item =new GetJZJLListRequestItem();
          item.setDeptName(item3s.get(i).getDeptName());
          item.setDoctName(item3s.get(i).getDoctName());
          item.setOperDateTime(item3s.get(i).getOperDateTime());
          item.setRankName("");
          item.setRegID(item3s.get(i).getRegID());
          item.setTotalFee("");
        items.add(item);
        }

        GetJZJLListResponse response =new GetJZJLListResponse();
        response.setResultCode("0");
        response.setResultMsg("交易成功！");
        response.setItems(items);
        return  response;
    }

return  null;
    }
}
